<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../assets/swiper/css/swiper.min.css">
    <style>
        body{
            padding-bottom: 800px;
            padding-left: 30px;
        }
        .swiper-container{
            width: 500px;
            height: 300px;
            border: 1px solid black;
        }
        .swiper-container img{
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    </style>
</head>
<body>
    <div id="app">

        <div v-for=" box in list ">
            <h4>{{ box.name }}</h4>
            <div class="swiper-container" ref="loop">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for="item in box.list">
                        <img :src="`https://oa.itany.com/itmupload/${item.annex.path}`" alt="" srcset="">
                    </div>
                </div>
            </div>
            <hr>
        </div>

    </div>
    <script src="../assets/swiper/js/swiper.js"></script>
    <script type="module">
        import axios from "../assets/axios-es/axios.js";
        // 加载 Vue3 的ESM 模块文件
        import { createApp } from "../assets/vue3/vue.esm-browser.js"
        createApp({
            data(){
                return {
                    list:[]
                }
            },
            methods: {
                async loadLoopData() {
                    let { data } = await axios.get("https://oa.itany.com/ItanyManager/web/findRotation",{
                        params:{
                            type:1,
                            sortid:1
                        }
                    })
                    this.list = [
                        {
                            name:"第一个轮播图",
                            list:data.data
                        },
                        {
                            name:"第二个轮播图",
                            list:data.data
                        },
                        {
                            name:"第三个轮播图",
                            list:data.data
                        }
                    ]
                    await this.$nextTick();
                    // vue3 如果 页面容器中存在多个ref取值相同的DOM节点，vue容器构建时会将这些节点组成数组记录在$refs 中
                    for (let loopBox of this.$refs.loop) {
                        new Swiper(loopBox,{})
                    }
                    
                }
            },
            mounted () {
                this.loadLoopData();
            },
        }).mount("#app")
    </script>
</body>
</html>